package com.lihui;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2022/09/23  19:28
 */

class MyArray {
    private Object[] arrays = new Object[10];

    // 这里先不做非空，越界等校验，只做演示
    public void setValue (int pos, Object value) {
        arrays[pos] = value;
    }

    public Object getPos (int pos) {
        return arrays[pos];
    }
}
public class Demo01 {
    public static void main(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setValue(0, 10);
        myArray.setValue(1, "hello");
        myArray.setValue(2, "3.14");
        myArray.setValue(3, new Object());

        // 现在打印会不会出现问题
        System.out.println(myArray.getPos(0));
        System.out.println(myArray.getPos(1));
        System.out.println(myArray.getPos(2));
        System.out.println(myArray.getPos(3));

        System.out.println("============================");
        Integer val02 = (Integer) myArray.getPos(0);
        String val01 = (String) myArray.getPos(1);
        System.out.println(val01);
        System.out.println(val02);

        Integer val03 = (Integer) myArray.getPos(1);
        System.out.println(val03);

    }
}
